package day3.demo2;

import day2.demo2.entity.Result;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

@RestController
@ControllerAdvice//表示全局异常处理类,给前端返回Result对象
public class GloEx {
    @ExceptionHandler(Exception.class)
    public Result exe1Handle(Exception e, Model m) {
        Result r = new Result();
        r.setExtra(e.getMessage());
        return r;
    }
}